﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;

namespace GEPL.StandardModulesLibrary.Converters
{
    /// <summary>
    /// Converts between negated bool value and Visibility enum
    /// </summary>
    public sealed class NegBoolToVisibilityConverter : IValueConverter
    {
        private readonly BooleanToVisibilityConverter converter = new BooleanToVisibilityConverter();

        private BooleanToVisibilityConverter _converter = new BooleanToVisibilityConverter();

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var result = converter.Convert(value, targetType, parameter, culture) as Visibility?;
            return result == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var result = converter.ConvertBack(value, targetType, parameter, culture) as bool?;
            return result != true;
        }
    }
}